home *** CD-ROM | disk | FTP | other *** search
/ Internet.Works 39 / Issue 39.iso / pc / PCSoftware / RoboHelp / DISK1 / DATA.1 / ShowWebHelp.js < prev    next >
Encoding:
JavaScript  |  2000-06-27  |  5.4 KB  |  161 lines

  1. // eHelpÆ Corporation
  2. // Copyright© 1998-2000 eHelpÆ Corporation.All rights reserved.
  3. // ShowWebHelp.js 
  4. // This is a Helper js file for WebHelp Content Sensitive Help. 
  5. // Contents used as the Options for widnow.open.
  6. // Now Only support for IE4 and above and NS4.
  7.  
  8. var WOF_LOCATION    = 0x1;
  9. var WOF_MENUBAR        = 0x2;
  10. var WOF_RESIZABLE    = 0x4;
  11. var WOF_TOOLBAR        = 0x8;
  12. var WOF_STATUS        = 0x10;
  13. var WOF_SCROLLBARS    = 0x20;
  14.  
  15.  
  16. // the parameter user can set from their own JavaScript.
  17. var gbWindowOption  = WOF_SCROLLBARS | WOF_RESIZABLE;
  18. var gbWindowPosLeft = 0;
  19. var gbWindowPosTop    = 0;
  20. var gbWindowPosWidth    = 400;
  21. var gbWindowPosHeight    = 400;
  22.  
  23. // the Helper function will invoke the Webhelp Content Sensitive Help
  24. // here strUrl should be the <relative Path>/**_csh.htm#parameter
  25. // or you can specify the abs path. or URL.
  26. // user also can pass window option through strURL.
  27.  
  28. var swh_strAgent   = navigator.userAgent.toLowerCase();
  29.  
  30. var swh_IE     = (swh_strAgent.indexOf("msie") != -1);
  31.  
  32. function ShowWebHelp(strUrl)
  33. {
  34.     var strHelpOptions = "";
  35.     
  36.     var nUserOptionPos = strUrl.indexOf(",");
  37.     var strUsrWindowOption = "";
  38.  
  39.     if (nUserOptionPos != -1) {
  40.         strUsrWindowOption = strUrl.substring(nUserOptionPos+1);
  41.         strUrl = strUrl.substring(0, nUserOptionPos);
  42.     }
  43.     if (strUsrWindowOption.indexOf("location=") == -1) {
  44.         if (gbWindowOption & WOF_LOCATION)            // Show/Hide Address bar {yes | no}
  45.             strHelpOptions += ",location=yes";
  46.         else
  47.             strHelpOptions += ",location=no";
  48.     }
  49.  
  50.     if (strUsrWindowOption.indexOf("toolbar=") == -1) {        
  51.         if (gbWindowOption & WOF_TOOLBAR)            // Show/Hide Toolbar {yes | no}
  52.             strHelpOptions += ",toolbar=yes";        
  53.         else
  54.             strHelpOptions += ",toolbar=no";        
  55.     }
  56.  
  57.     if (strUsrWindowOption.indexOf("menubar=") == -1) {
  58.         if (gbWindowOption & WOF_MENUBAR)            // Show/Hide Menubar {yes | no}
  59.             strHelpOptions += ",menubar=yes";        
  60.         else
  61.             strHelpOptions += ",menubar=no";
  62.     }
  63.  
  64.     if (strUsrWindowOption.indexOf("status=") == -1) {
  65.         if (gbWindowOption & WOF_STATUS)            // Show/Hide Statusbar {yes | no}
  66.             strHelpOptions += ",status=yes";        
  67.         else
  68.             strHelpOptions += ",status=no";        
  69.     }
  70.  
  71.     if (strUsrWindowOption.indexOf("scrollbars=") == -1) {
  72.         if (gbWindowOption & WOF_SCROLLBARS)            // Show/Hide Scrollbar {yes | no}
  73.             strHelpOptions += ",scrollbars=yes";
  74.         else
  75.             strHelpOptions += ",scrollbars=no";    
  76.     }
  77.  
  78.     if (strUsrWindowOption.indexOf("resizable=") == -1) {
  79.         if (gbWindowOption & WOF_RESIZABLE)            // Allow help window resizing {yes | no}
  80.             strHelpOptions += ",resizable=yes";
  81.         else
  82.             strHelpOptions += ",resizable=no";
  83.     }
  84.  
  85.     if (strUsrWindowOption.indexOf("top=") == -1) 
  86.         strHelpOptions += ",top=" + gbWindowPosTop;        // Top position for help window (in pixels)
  87.  
  88.     if (strUsrWindowOption.indexOf("screenY=") == -1) 
  89.         strHelpOptions += ",screenY=" + gbWindowPosTop;        // Top position for help window (in pixels)(for netscape)
  90.  
  91.     if (strUsrWindowOption.indexOf("left=") == -1) 
  92.         strHelpOptions += ",left=" + gbWindowPosLeft;        // Left position for help window (in pixels)
  93.  
  94.     if (strUsrWindowOption.indexOf("screenX=") == -1)
  95.         strHelpOptions += ",screenX=" + gbWindowPosLeft;    // Left position for help window (in pixels)(for netscape)
  96.  
  97.     if (strUsrWindowOption.indexOf("width=") == -1)
  98.         strHelpOptions += ",width=" + gbWindowPosWidth;        // Width of help window (in pixels)
  99.  
  100.     if (strUsrWindowOption.indexOf("outerWidth=") == -1)
  101.         strHelpOptions += ",outerWidth=" + gbWindowPosWidth;    // Width of help window (in pixels) (for netscape)
  102.  
  103.     if (strUsrWindowOption.indexOf("height=") == -1)    
  104.         strHelpOptions += ",height=" + gbWindowPosHeight;    // Height of help window (in pixels)
  105.  
  106.     if (strUsrWindowOption.indexOf("outerHeight=") == -1)
  107.         strHelpOptions += ",outerHeight=" + gbWindowPosHeight;    // Height of help window (in pixels) (for netscape)
  108.  
  109.  
  110.     if (strUsrWindowOption.length <= 0) 
  111.         strHelpOptions = strHelpOptions.substring(1);         // remove the comma.
  112.  
  113.     if ((strUsrWindowOption.length > 0) && (strUsrWindowOption.lastIndexOf(",") == (strUsrWindowOption.length - 1))) 
  114.         strUsrWindowOption = strUsrWindowOption.substring(0, strUsrWindowOption.length - 1);    // remove the comma.
  115.  
  116.  
  117.     // if it is a remote url convert : to ? 
  118.     var npos1 = strUrl.indexOf("#RemoteURL=");
  119.     if (npos1 != -1 ) {
  120.         var npos2 = strUrl.indexOf("://", npos1);
  121.         if (npos2 != -1 ) {
  122.             strUrl = strUrl.substring(0, npos2) + "%072%057%057" + strUrl.substring(npos2+3);
  123.         }
  124.     }
  125.     if (swh_IE) {
  126.         strUrl = strUrl+","+ strUsrWindowOption + strHelpOptions;
  127.         strHelpOptions = "left=2000,top=2000,height=1,width=1";
  128.         window.open(strUrl, "HelpSecondary", strHelpOptions);
  129.     }
  130.     else {
  131.         strHelpOptions = strUsrWindowOption + strHelpOptions;
  132.         window.open(strUrl, "HelpStub", strHelpOptions);
  133.     }
  134. }
  135.  
  136. // Here is a tiny sample.
  137. //<HTML>
  138. //
  139. //<HEAD>
  140. //   <TITLE>I need some help</TITLE>
  141. //   
  142. //   <SCRIPT LANGUAGE="JavaScript" src="showwebhelp.js">
  143. //   </SCRIPT>
  144. //
  145. //</HEAD>
  146. //
  147. //<BODY>
  148. //<SCRIPT>
  149. //    gbWindowPosLeft = 10;
  150. //    gbWindowPosWidth = 700;
  151. //</SCRIPT>
  152. //   How about a little <A HREF='javascript:ShowWebHelp("africa_csh.htm#TopicNumber=1,location=yes,left=30")'>Help (topicnumber)</A>
  153. //   How about a little <A HREF='javascript:ShowWebHelp("africa_csh.htm#TopicId=TopicID1")'>Help (topicID)</A>
  154. //   How about a little <A HREF='javascript:ShowWebHelp("africa_csh.htm#RemoteURL=http://www.ehelp.com")'>Help (RemoteURL)</A>
  155. //
  156. //</BODY>
  157. //
  158. //
  159. //</HTML>
  160. //
  161.